package xdu.lz.netty.g_handler.tcp_handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author lizhen
 * @date 2019/8/24 23:19
 * @desc
 */
public class MyPersonEncoder extends MessageToByteEncoder<PersonProtocol> {
    private int count = 0;
    @Override
    protected void encode(ChannelHandlerContext ctx, PersonProtocol msg, ByteBuf out) throws Exception {
        this.count ++;
        System.out.println("MyPersonEncoder encode invoke!");
        out.writeInt(msg.getLength());
        out.writeBytes(msg.getContent());
    }
}
